package com.zj.base.permission.checker;

import android.app.Activity;
import android.content.DialogInterface;

import com.zj.base.permission.ConfigurationModules;
import com.zj.base.permission.interfaces.OnActionClickListener;
import com.zj.base.permission.utils.JumpToSettingUtils;

import static com.zj.base.permission.manifests.Op_PermissionCheekUtils.Manifest.NONE;

/**
 * Created by zhaojie on 2018/5/30.
 */

public class Lower_checker extends BasePermissionChecker {

    public Lower_checker(Activity activity) {
        super(activity);
    }

    @Override
    public void check() {
        StringBuffer sb = new StringBuffer();
        for (ConfigurationModules module : getPermissions()) {
            String permissionsNames = (module.summary + "。(+" + (module.isForce ? "必要" : "可选") + ")\n");
            sb.append(permissionsNames);
        }
        ConfigurationModules module = new ConfigurationModules(false, NONE, "检测到您的手机系统Android版本过低，请您前往系统设置或安全管家开启如下权限：\n" + sb.toString(), "", "", "");
        showAlert(false, module, new OnActionClickListener() {
            @Override
            public void cancel(DialogInterface dialog) {
                if (listener != null)
                    listener.onSuccess(getPermissions());
            }

            @Override
            public void fulfil(DialogInterface dialog) {
                JumpToSettingUtils.CheekAndJump(activity, PERMISSIONCODE);
            }
        });
    }
}
